package com.lianjia.sh.tools.service;

import com.lianjia.sh.tools.event.event.PropertyAddEvent;
import com.lianjia.sh.tools.event.model.Employee;
import com.lianjia.sh.tools.event.model.Property;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

/**
 * Created by yangsp1 on 16/6/24.
 */
@Component
public class PropertyService {

    @Autowired
    private ApplicationContext applicationContext;

    public void add(){
        System.out.println("新增了一条房源");

        PropertyAddEvent propertyAddEvent = new PropertyAddEvent(this);
        Employee employee = new Employee();
        employee.setEmpNo(111);
        employee.setEmpName("老杨叔叔");
        employee.setPhone("15011401122");

        Property property = new Property();
        property.setPropertyId("1111111");
        property.setRoomNo("22A");

        propertyAddEvent.setLoginEmp(employee);
        propertyAddEvent.setProperty(property);
        applicationContext.publishEvent(propertyAddEvent);

        System.out.println("新增房源结束了。。。。。。。。。。");
    }
}
